package com.zzk.lanouhn.myapplication1.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by lanouhn on 16/9/1.
 */
public class MyFragmentAdapter extends FragmentPagerAdapter {
    private List<Fragment> lists;
    private List<String> titles;//放置在tabLayout中的标题列表

    public MyFragmentAdapter(FragmentManager fm, List<String> titles, List<Fragment> lists) {
        super(fm);
        this.titles = titles;
        this.lists = lists;
    }

    @Override
    public Fragment getItem(int position) {
        return lists.get(position);
    }

    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
        //返回每一个fragment对应的标题
    }
}
